package cn.blog.service.front;

import java.sql.Date;
import java.util.List;

import cn.blog.dao.conn.ParamSet;
import cn.blog.dao.front.ArtilceDao;
import cn.blog.dao.front.ComDao;
import cn.blog.dao.front.UserDao;
import cn.blog.entity.origin.Article;
import cn.blog.entity.origin.Commet;
import cn.blog.entity.origin.User;

public class ArticleService {
	private ArtilceDao artDao;
	private UserDao userDao;
	private ComDao comDao;

	public ArticleService() {
		artDao = new ArtilceDao();
		userDao = new UserDao();
		comDao = new ComDao();
	}
	
	/**
	 * 根据文章编号查询文章信息
	 * @param artId	章编号
	 * @return	文章对象
	 */
	public Article art(int artId) {
		String sql = "SELECT * FROM tb_article WHERE art_id = ?";
		return artDao.art(artId);
	}
	
	/**
	 * 根据文章编号查询评论
	 * @param artId 文章编号
	 * @return	评论集合
	 */
	public List<Commet> comAll(int artId){
		
		return comDao.comAll(artId);
	}
	
	/**
	 * 根据用户编号获取用户信息
	 * @param userId	用户编号
	 * @return	用户对象
	 */
	public User getUser(int userId) {
		return userDao.getUser(userId);
		
	}
	
	/**
	 * 根据用户名获取用户id
	 * @param uname	用户名
	 * @return	用户id
	 */
	public int getuserId(String uname) {
		
		return  userDao.getuserId(uname);
	}

	public int addCom(int articleId, int userId, String comPeoName, String comText, Date comTime) {
		return	comDao.addCom(articleId,userId,comPeoName,comText,comTime);
		
	}

	public int updateRead(int read, int artId) {
		return artDao.updateRead(read,artId);
		// TODO Auto-generated method stub
		
	}
	
}
